#ifndef BSP_MAIN_H
#define BSP_MAIN_H

#include "cod4map2.h"

#define LUMPNUM 32
#define LUMP_SHADERS 0
#define LUMP_LIGHTMAPS 1
#define LUMP_PLANES 2
#define LUMP_BRUSHSIDES 3
#define LUMP_BRUSHES 4
#define LUMP_FOGS 5
#define LUMP_TSOUP 6
#define LUMP_DVERTS 7 
#define LUMP_DINDEXES 8
#define LUMP_CULLGROUPS 9
#define LUMP_CULLGROUPINDEXES 10
#define LUMP_PORTALVERTS 11 
#define LUMP_OCCLUDER 12
#define LUMP_OCCLUDERPLANES 13
#define LUMP_OCCLUDEREEDGES 14
#define LUMP_OCCLUDERINDEXES 15
#define LUMP_AABB 16
#define LUMP_CELLS 17
#define LUMP_PORTALS 18
#define LUMP_LIGHTINDEXES 19
#define LUMP_NODES 20
#define LUMP_LEAFS 21
#define LUMP_LEAFBRUSHES 22
#define LUMP_LEAFSURFACES 23
#define LUMP_PATCHCOLLISION 24
#define LUMP_COLLISIONVERTS 25
#define LUMP_COLLISIONINDEXES 26
#define LUMP_MODELS 27
#define LUMP_VISIBILITY 28
#define LUMP_ENTITIES 29
#define LUMP_LIGHTS 30 
/* FOR SAKE OF COMPLETENESS */
#define LUMP_UNKNOWN1 31
#define LUMP_UNKNOWN2 32

using namespace std;

class BSP{
public:
		BSP();
		~BSP();

		void LoadBSP(string filename);

		void UnloadBSP();

		void WriteBSP(string filename);

		int ExportLightmapsMain(int argc, char** argv);
		int ImportLightmapsMain(int argc, char** argv);

		int ConvertBSPMain(int argc, char** argv);

private:
	   
	ifstream input;
	/* THESE POINTERS USED IN BSP'S SCOPE TO FILL BEFORE PUSHING TO VECTORS*/
	/**/bspHeader_t* pheader; 
	/**/bspTexture_t* ptexture;
	/**/bspPlane_t* pplane;
	/**/bspBrushSide_t* pbrushside;
	/**/bspBrush_t* pbrush;
	/**/bspVertex_t* pvertex;
	/**/bspFace_t* pface;
	/* END STRUCT POINTER BLOCK */

	/* THESE VECTORS CONTAIN THE FILLED STRUCTS FOR N NUMBER OF LUMP TYPE*/
	/**/vector<bspTexture_t> textures;
	/**/vector<bspPlane_t> planes;
	/**/vector<bspBrushSide_t> brushsides;
	/**/vector<bspBrush_t> brush;
	/**/vector<bspVertex_t> vertices;
	/**/vector<bspFace_t> faces;
	/* END VECTOR CONTAINER BLOCK */

		void LoadShaderLump();
		void LoadLightmapsLump();
		void LoadPlanesLump();
		void LoadBrushSidesLump();
		void LoadBrushesLump();
		void LoadFogsLump();
		void LoadTSoupLump();
		void LoadDVertsLump();
		void LoadDIndexesLump();
		void LoadCullgroupsLump();
		void LoadCullgroupIndexesLump();
		void LoadPortalVertsLump();
		void LoadOccludersLump();
		void LoadOccluderPlanesLump();
		void LoadOccluderEdgesLump();
		void LoadOccluderIndexesLump();
		void LoadAABBLump();
		void LoadCellsLump();
		void LoadPortalsLump();
		void LoadLightIndexLump();
		void LoadNodesLump();
		void LoadLeafsLump();
		void LoadLeafBrushesLump();
		void LoadLeafSurfacesLump();
		void LoadPatchCollisionLump();
		void LoadCollisionVertsLump();
		void LoadCollisionIndexesLump();
		void LoadModelsLump();
		void LoadVisibilityLump();
		void LoadEntitiesLump();
		void LoadLightsLump(); //NOT lightmaps!!
		void LoadUnknown1Lump();
		void LoadUnknown2Lump();
};





#endif